﻿

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>高定设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">高定配置</div>
                    <div class="layui-card-body">

                        <div class="layui-form" wid100 lay-filter="">
                            <div class="layui-form-item">
                                <label class="layui-form-label" style="width: 120px;">收货日期增加天数</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="txt_shrq_add" lay-verify="number" id="txt_shrq_add" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">单位为天</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">订单加急天数</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="txt_jjts" lay-verify="number" id="txt_jjts" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">单位为天</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">订单加急费用</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="txt_jjfy" id="txt_jjfy" lay-verify="number" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">单位为元</div>
                            </div>

                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="set_system_order">确认保存</button>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/js/cookie.js"></script>
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'set', 'form'], function () {
            var $ = layui.$
                , form = layui.form
                , upload = layui.upload;
            var isfirst=false;
            //加载修改信息
            $.ajax({
                url: 'ashx/list.ashx?type=getlist_byorderset',
                type: 'GET',
                success: function (data) {
                    var str = "";
                    if (data.data.length > 0) {
                        for (var i = 0; i < data.data.length; i++) {
                            $("#txt_shrq_add").val(data.data[i].shrq_add);
                            $("#txt_jjts").val(data.data[i].jjts);
                            $("#txt_jjfy").val(data.data[i].jjfy);
                        }
                    }
                    else {
                        isfirst = true;
                    }

                }
            })


            //监听提交
            form.on('submit(set_system_order)', function (data) {
                var txt_jjts = $("#txt_jjts").val();
                var txt_jjfy = $("#txt_jjfy").val();
                var txt_shrq_add = $("#txt_shrq_add").val();
                var arr = new Array();
                if (txt_shrq_add == "" || txt_shrq_add == null || txt_shrq_add == undefined) {
                    layer.msg('请填写加收货日期增加天数', { icon: 5 });
                    return;
                }
                if (txt_jjts == "" || txt_jjts == null || txt_jjts == undefined) {
                    layer.msg('请填写加急天数', { icon: 5 });
                    return;
                }
                if (txt_jjfy == "" || txt_jjfy == null || txt_jjfy == undefined) {
                    layer.msg('请填写加急费用', { icon: 5 });
                    return;
                }

                if (txt_jjts != "") {
                    var add = {
                        "userid": $.cookie("id"),
                        "shrq_add": txt_shrq_add,
                        "jjts": txt_jjts,
                        "jjfy": txt_jjfy
                    };
                    arr.push(add);
                    $.ajax({
                        url: 'ashx/list.ashx?type=edit&isfirst=' + isfirst,
                        type: "post",
                        contentType: "application/json",
                        dataType: "json",
                        data: JSON.stringify({ 'LoadData_type': arr }),
                        success: function (res) {
                            if (res.flag == "True") {
                                layer.msg(res.remsg, {
                                    time: 2000,
                                    end: function () {
                                        window.location.reload();
                                    }
                                })
                            }
                            else {
                                layer.alert(res.remsg);
                            }
                        }
                    })
                }
            });
        }
        );
    </script>
</body>
</html>